//
// Created by xili on 2024/8/8 20:26.
// Go big or go home.
//
#include <vector>
#include <algorithm>

using namespace std;

struct ListNode {
    int val;
    ListNode *next;

    ListNode() : val(0), next(nullptr) {}

    ListNode(int x) : val(x), next(nullptr) {}

    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

class Solution {
public:
    vector<int> reverseBookList(ListNode *head) {
        vector<int> ans;
        ListNode *p = head;
        while (p) {
            ans.push_back(p->val);
            p = p->next;
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
};